package com.peanut.baby.mvp.livedetail.livegroupdetail;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.peanut.baby.R;
import com.peanut.baby.model.LiveGroup;
import com.peanut.baby.model.LiveRoom;
import com.peanut.baby.mvp.livedetail.LiveDetailActivity;
import com.peanut.baby.mvp.mycontent.MyContentActivity;
import com.peanut.devlibrary.widget.pullrecycle.BaseRecyclerAdapter;
import com.peanut.devlibrary.widget.pullrecycle.BaseViewHolder;

import java.util.List;

/**
 * Created by anonymouslystudio on 2017/8/21.
 */

public class LiveGroupTabRecyclerAdapter extends BaseRecyclerAdapter<LiveGroup> {
    boolean isContentActivity = false;
    private int type;
    private Context context;

    public LiveGroupTabRecyclerAdapter(Context context, List<LiveGroup> data, int type) {
        super(context, data);
        this.type = type;
        this.context = context;
        if (context instanceof MyContentActivity) {
            isContentActivity = true;
        }
    }


    @Override
    protected void convert(BaseViewHolder holder, LiveGroup item, int position) {
        super.convert(holder, item, position);
        ImageView playStatus = holder.getView(R.id.comment_avatar);
        TextView nick = holder.getView(R.id.roomtitle);
        TextView time = holder.getView(R.id.isEnrole);
        nick.setText(item.name);
        if (item.isEnrole == 1) {
            time.setText("已报名");
        } else {
            time.setText("未报名");
        }
        if(item.playStatus==1){
            playStatus.setImageResource(R.drawable.icon_playing);
        } else {
            playStatus.setImageResource(R.drawable.icon_play);
        }
        nick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                LiveDetailActivity.start(context,(int)item.roomId,1);
            }
        });
    }

    @Override
    protected void convert(BaseViewHolder holder, final LiveGroup item) {
    }

    @Override
    protected int getLayoutId() {
        return R.layout.layout_item_livegroup_room;
    }

}
